<template>
  <el-container class="app-container">
    <!-- 顶部导航栏 -->
    <el-header class="app-header">
      <div class="header-left">
        <el-icon class="menu-toggle" @click="isCollapse = !isCollapse">
          <Fold v-if="!isCollapse" />
          <Expand v-else />
        </el-icon>
        <h1 class="app-title">vue2测试项目</h1>
      </div>
      <div class="header-right">
        <el-button type="text">
          <el-icon><Bell /></el-icon>
        </el-button>
        <el-avatar
          size="small"
          src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"
        />
      </div>
    </el-header>

    <el-container class="main-container">
      <!-- 左侧导航栏 -->
      <el-aside :width="isCollapse ? '64px' : '240px'" class="app-aside">
        <el-menu :default-active="$route.path" :collapse="isCollapse" router class="app-menu">
          <el-menu-item index="/">
            <el-icon><HomeFilled /></el-icon>
            <template #title>首页</template>
          </el-menu-item>

          <el-menu-item index="/TodoApp">
            <el-icon><Document /></el-icon>
            <template #title>TodoList</template>
          </el-menu-item>

          <el-menu-item index="/about">
            <el-icon><InfoFilled /></el-icon>
            <template #title>关于我们</template>
          </el-menu-item>
        </el-menu>
      </el-aside>

      <!-- 主要内容区域 -->
      <el-main class="app-main">
        <!-- <div class="breadcrumb-container">
          <el-breadcrumb>
            <el-breadcrumb-item to="/">首页</el-breadcrumb-item>
            <el-breadcrumb-item>{{ $route.name }}</el-breadcrumb-item>
          </el-breadcrumb>
        </div> -->

        <!-- 添加标签页组件 -->
        <tabs-view />

        <div class="main-content">
          <router-view></router-view>
        </div>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import TabsView from '@/components/TabsView.vue'
import { ref } from 'vue'
import { HomeFilled, InfoFilled, Document, Bell, Fold, Expand } from '@element-plus/icons-vue'

export default {
  name: 'App',
  components: {
    TabsView,
    HomeFilled,
    InfoFilled,
    Document,
    Bell,
    Fold,
    Expand,
  },
  setup() {
    const isCollapse = ref(false)
    return {
      isCollapse,
    }
  },
}
</script>

<style>
:root {
  --header-height: 60px;
  --aside-width: 240px;
  --collapsed-aside-width: 64px;
  --primary-bg: #ffffff;
  --secondary-bg: #f5f7fa;
  --border-color: #e4e7ed;
  --text-primary: #303133;
  --text-secondary: #606266;
}

body {
  margin: 0;
  font-family:
    'Inter',
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    Roboto,
    Oxygen,
    Ubuntu,
    Cantarell,
    'Open Sans',
    'Helvetica Neue',
    sans-serif;
  -webkit-font-smoothing: antialiased;
  color: var(--text-primary);
  background-color: var(--secondary-bg);
}

.app-container {
  min-height: 100vh;
}

/* 顶部导航样式 */
.app-header {
  height: var(--header-height);
  background: var(--primary-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.app-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.menu-toggle {
  font-size: 20px;
  cursor: pointer;
  color: var(--text-secondary);
}

/* 侧边栏样式 */
.app-aside {
  background: var(--primary-bg);
  border-right: 1px solid var(--border-color);
  transition: width 0.3s;
  position: fixed;
  top: var(--header-height);
  bottom: 0;
  left: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

.app-menu {
  border-right: none;
  height: 100%;
}

.app-menu:not(.el-menu--collapse) {
  width: var(--aside-width);
}

/* 主内容区样式 */
.main-container {
  margin-top: var(--header-height);
}

.app-main {
  margin-left: v-bind(isCollapse ? 'var(--collapsed-aside-width)': 'var(--aside-width)');
  padding: 20px;
  background-color: var(--secondary-bg);
  min-height: calc(100vh - var(--header-height));
  transition: margin-left 0.3s;
}

.breadcrumb-container {
  margin-bottom: 16px;
  padding: 8px 16px;
  background: var(--primary-bg);
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.main-content {
  margin-top: 8px;
  padding: 20px;
  background: var(--primary-bg);
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}

/* 滚动条美化 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-thumb {
  background: #cfd3dc;
  border-radius: 3px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* 过渡动画 */
.el-menu-item {
  transition: all 0.3s ease;
}

.el-menu-item:hover {
  background-color: var(--secondary-bg) !important;
}

.el-menu-item.is-active {
  position: relative;
  background-color: var(--secondary-bg) !important;
}

.el-menu-item.is-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background-color: var(--el-color-primary);
  transition: all 0.3s ease;
}
</style>
